home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 4
/
Amiga Tools 4.iso
/
tools
/
disk-tools
/
misc
/
floppy
/
setboot.s
< prev
next >
Wrap
Text File
|
1996-02-26
|
5KB
|
136 lines
*****************************************************************************
* SET BOOT CODE *
* Compiler: Devpac 3.04 ORHAN *
*****************************************************************************
MACHINE MC68000
INCLUDE "exec/types.i"
INCLUDE "exec/resident.i"
INCLUDE "libraries/expansionbase.i"
INCLUDE "lvo/exec_lib.i"
XDEF _SetBoot
XDEF _ClrBoot
XDEF _BootChkSum
XDEF _EvalChkSum
*****************************************************************************
* arg1= bootblock adr, arg2= length, arg3= rootblock, ret= 0 if succesful *
*****************************************************************************
SECTION "CODE",CODE
_SetBoot:
LEA.L 4(SP),A0 ;arg ptr
MOVEM.L D2/A2,-(SP)
MOVE.L 0(A0),A2 ;get bootblock adr
MOVE.L 4(A0),D2 ;get length
MOVE.L 8(A0),D1 ;get rootblock
CMP.L #LENBOOT+12,D2
BLO ERROR
MOVE.L D1,8(A2) ;set rootblock
LEA.L 12(A2),A0
MOVE.L D2,D0
LSR.L #2,D0
SUB.L #3+1,D0
AA7: CLR.L (A0)+ ;clear bootblock
DBF D0,AA7
LEA.L BOOTCODE,A0
LEA.L 12(A2),A1
MOVE.L #LENBOOT-1,D0
AA2: MOVE.B (A0)+,(A1)+ ;copy boot code
DBF D0,AA2
MOVE.L D2,-(SP)
MOVE.L A2,-(SP)
BSR _EvalChkSum
ADD.L #8,SP
MOVE.L #0,D0
EXIT:
MOVEM.L (SP)+,D2/A2
RTS
ERROR: MOVE.L #-1,D0
BRA EXIT
*****************************************************************************
* clear bootblock *
* arg1= boot block adr, arg2= length *
*****************************************************************************
_ClrBoot:
MOVE.L 4(SP),A0 ;get boot block adr
MOVE.L 8(SP),D0 ;get length
LEA.L 4(A0),A0
LSR.L #2,D0
SUB.L #1+1,D0
AA5: CLR.L (A0)+
DBF D0,AA5
RTS
*****************************************************************************
* checks bootblock checksum *
* arg1= bootblock adr, arg2= length, ret= 0 if successful *
*****************************************************************************
_BootChkSum:
MOVE.L 4(SP),A0 ;get bootblock adr
MOVE.L 8(SP),D1 ;get length
CLR.L D0
LSR.L #2,D1
SUB.L #1,D1
AA4: ADD.L (A0)+,D0
BCC.S AA3
ADD.L #1,D0
AA3: DBF D1,AA4
NOT.L D0
RTS
*****************************************************************************
* calculate bootblock checksum and update it *
* arg1= bootblock adr, arg2= length *
*****************************************************************************
_EvalChkSum:
MOVE.L 4(SP),A0 ;get bootblock adr
MOVE.L 8(SP),D0 ;get length
LEA.L 4(A0),A1
CLR.L (A1)
CLR.L D1
LSR.L #2,D0
SUB.L #1,D0
AA6: ADD.L (A0)+,D1
BCC.S AA1
ADD.L #1,D1
AA1: DBF D0,AA6
NOT.L D1
MOVE.L D1,(A1)
RTS
*****************************************************************************
* STANDARD BOOT CODE (KICKSTART R2.0-R3.0) *
*****************************************************************************
BOOTCODE:
LEA.L EXPNAME(PC),A1
MOVEQ.L #37,D0
CALLSYS OpenLibrary
TST.L D0
BEQ.W AA0
MOVE.L D0,A1
BSET.B #EBB_SILENTSTART,eb_Flags(A1)
CALLSYS CloseLibrary
AA0:
LEA.L DOSNAME(PC),A1
CALLSYS FindResident
TST.L D0
BEQ.W EXITSYS2
MOVE.L D0,A0
MOVE.L RT_INIT(A0),A0
EXITSYS:
MOVEQ.L #0,D0
RTS
EXITSYS2:
MOVEQ.L #-1,D0
RTS
DOSNAME DC.B 'dos.library',0
EXPNAME DC.B 'expansion.library',0
LENBOOT EQU *-BOOTCODE
END